package com.ieasy.module.oa.project.web.action;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ieasy.basic.model.DataGrid;
import com.ieasy.basic.model.Msg;
import com.ieasy.basic.util.cons.Const;
import com.ieasy.module.common.web.action.BaseController;
import com.ieasy.module.oa.project.service.IPersonBudgetService;
import com.ieasy.module.oa.project.web.form.PersonBudgetForm;

@Controller
@RequestMapping("/admin/oa/person_budget")
public class PersonBudgetAction extends BaseController {
	
	@Autowired
	private IPersonBudgetService budgetService ;
	
	/**
	 * 人员需求预算部长输入页面
	 * @return
	 */
	@RequestMapping("/person_budget_main_UI.do")
	public String person_budget_main_UI() {
		return Const.PROJECT + "person_budget_main_UI" ;
	}
	
	/**
	 * 人员需求预测部门数据列表
	 * @return
	 */
	@RequestMapping("/person_budget_dept_UI.do")
	public String person_budget_dept_UI() {
		return Const.PROJECT + "person_budget_dept_UI" ;
	}
	
	/**
	 * 全部人员统计
	 * @return
	 */
	@RequestMapping("/person_budget_all_report_UI.do")
	public String person_budget_all_report_UI() {
		return Const.PROJECT + "person_budget_all_report_UI" ;
	}
	
	/**
	 * 创建或修改数据
	 * @param form
	 * @return
	 */
	@RequestMapping("/addOrUpdate.do")
	public @ResponseBody Msg addOrUpdate(PersonBudgetForm form) {
		return this.budgetService.addOrUpdate(form) ;
	}
	
	
	/**
	 * 部长数据录入计算
	 * @param form
	 * @return
	 */
	@RequestMapping("/person_budget_datagrid.do")
	public @ResponseBody DataGrid person_budget_datagrid(PersonBudgetForm form) {
		return this.budgetService.dagagrid(form) ;
	}
	
	/**
	 * 部长数据录入计算
	 * @param form
	 * @return
	 */
	@RequestMapping("/person_budget_dept_list.do")
	public @ResponseBody List<PersonBudgetForm> person_budget_dept_list(Integer searchYear) {
		return this.budgetService.getAllPersonBudgetList(searchYear) ;
	}
	
	/**
	 * 全部人员统计
	 * @param searchYear
	 * @return
	 */
	@RequestMapping("/person_budget_all_report_list.do")
	public @ResponseBody List<Map<String, Object>> person_budget_all_report_list(Integer searchYear) {
		return this.budgetService.getAllPersonBudgetReport(searchYear) ;
	}
	
	@RequestMapping("/person_budget_dept_del_UI.do")
	public String person_budget_dept_del_UI() {
		return Const.PROJECT + "person_budget_dept_del_UI" ;
	}
	
	@RequestMapping("/deleteByPerson.do")
	public @ResponseBody Msg deleteByPerson(String id) {
		this.budgetService.deleteByPerson(id); 
		Msg msg = new Msg() ;
		msg.setStatus(true);
		msg.setMsg("删除成功...");
		return msg;
	}

}
